package com.tju320.elm;

import java.util.Scanner;

import com.tju320.elm.po.Admin;
import com.tju320.elm.po.Business;
import com.tju320.elm.view.AdminView;
import com.tju320.elm.view.BusinessView;
import com.tju320.elm.view.FoodView;
import com.tju320.elm.view.impl.AdminViewImpl;
import com.tju320.elm.view.impl.BusinessViewImpl;
import com.tju320.elm.view.impl.FoodViewImpl;

public class ElmBusinessEntry {
	Scanner keyboardInput = new Scanner(System.in);
	private void foodManage(Business business) {
		int menu = 0;
		FoodView fv = new FoodViewImpl();
		while (menu != 5) {
			System.out.println("二级菜单（食品管理）：1.查看食品列表2.新增食品3.修改食品4.删除食品5.返回一级菜单");
			System.out.println("请输入你的选择:");
			menu = keyboardInput.nextInt();
			switch (menu) {
			// 查看食品列表
			case 1:
				fv.showFoodList(business.getBusinessId());
				break;
			// 新增食品
			case 2:
				fv.saveFood(business.getBusinessId());
				break;
			// 修改食品
			case 3:
				fv.updateFood(business.getBusinessId());
				break;
			// 删除食品
			case 4:
				fv.removeFood(business.getBusinessId());
				break;
			// 返回一级菜单
			case 5:

				break;
			default:
				System.out.println("没有这个选项");
			}
		}
	}

	private void work() {
		System.out.println("饿了么管理后台（商家入口）");
		int menu = 0;
		BusinessView bv = new BusinessViewImpl();
		Business business=bv.login();
		while (business == null) {
			System.out.println("不存在此商家或密码错误,请再次输入");
			business = bv.login();
		}
		
		while (menu != 5) {
			System.out.println("一级菜单：1.查看商家信息2.修改商家信息3.更新密码4.所属商品管理5.退出系统");
			System.out.println("请输入你的选择:");
			menu = keyboardInput.nextInt();
			switch (menu) {
			// 查看商家信息
			case 1:
				bv.showBusiness(business.getBusinessId());
				break;
			// 修改商家信息
			case 2:
				bv.editBusiness(business.getBusinessId());
				break;
			// 更新密码
			case 3:
				bv.updateBusinessByPassword(business.getBusinessId());
				break;
			// 所属商品管理
			case 4:
				foodManage(business);

				break;
			// 退出系统
			case 5:
				System.out.println("欢迎你下次使用本系统");

				break;
			default:
				System.out.println("没有这个选项");
			}
		}

	}

	public static void main(String[] args) {
		new ElmBusinessEntry().work();
	}
}
